//package com.jiezhuo.config.mybatis;
//
//import com.baomidou.mybatisplus.annotation.DbType;
//import com.baomidou.mybatisplus.core.MybatisConfiguration;
//import com.baomidou.mybatisplus.core.MybatisXMLLanguageDriver;
//import com.baomidou.mybatisplus.core.config.GlobalConfig;
//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.apache.ibatis.type.JdbcType;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.annotation.Resource;
//import javax.sql.DataSource;
//
//@Configuration
//@MapperScan(basePackages = {"com.jiezhuo.mapper.jetlinks"}, sqlSessionFactoryRef = "sqlSessionFactoryJetlinks")
//public class JetlinksConfig {
//    @Resource
//    @Qualifier("jetlinks")
//    private DataSource jetlinks;
//
//    @Bean(name = "sqlSessionFactoryJetlinks")
//    public SqlSessionFactory sqlSessionFactoryJetlinks() throws Exception {
//        MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
//        sqlSessionFactory.setDataSource(jetlinks);
//
//        MybatisConfiguration configuration = new MybatisConfiguration();
//
//        configuration.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
//        configuration.setJdbcTypeForNull(JdbcType.NULL);
//        sqlSessionFactory.setConfiguration(configuration);
//        sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().
//                getResources("classpath*:com/jiezhuo/mapper/**/*.xml"));
//        sqlSessionFactory.setGlobalConfig(new GlobalConfig().setBanner(false));
//        sqlSessionFactory.setPlugins(mybatisPlusInterceptorJetlinks());
//        sqlSessionFactory.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
////        sqlSessionFactory.setTypeEnumsPackage();
//        return sqlSessionFactory.getObject();
//    }
//
//    @Bean(name = "JetlinksTransactionManager")
//    public DataSourceTransactionManager ds2TransactionManager() {
//        return new DataSourceTransactionManager(jetlinks);
//    }
//
//    @Bean
//    public MybatisPlusInterceptor mybatisPlusInterceptorJetlinks() {
//        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
//        return interceptor;
//    }
//
//    @Bean
//    public SqlSessionTemplate sqlSessionTemplateJetlinks() throws Exception {
//        SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactoryJetlinks());
//        return sqlSessionTemplate;
//    }
//}
